home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / content / nsIDocumentEncoder.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  10KB  |  269 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #ifndef nsIDocumentEncoder_h__
  39. #define nsIDocumentEncoder_h__
  40.  
  41. #include "nsISupports.h"
  42. #include "nsString.h"
  43.  
  44. class nsIDocumentEncoder;
  45. class nsIDocument;
  46. class nsIDOMRange;
  47. class nsISelection;
  48. class nsIOutputStream;
  49. class nsISupportsArray;
  50. class nsIDOMNode;
  51.  
  52.  
  53. #define NS_IDOCUMENT_ENCODER_IID                     \
  54. { /* a6cf9103-15b3-11d2-932e-00805f8add32 */         \
  55.     0xa6cf9103,                                      \
  56.     0x15b3,                                          \
  57.     0x11d2,                                          \
  58.     {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} \
  59.   }
  60.  
  61. #define NS_TEXT_ENCODER_CID                          \
  62. { /* e7ba1480-1dea-11d3-830f-00104bed045e */         \
  63.     0xe7ba1480,                                      \
  64.     0x1dea,                                          \
  65.     0x11d3,                                          \
  66.     {0x83, 0x0f, 0x00, 0x10, 0x4b, 0xed, 0x04, 0x5e} \
  67. }
  68.  
  69. #define NS_DOC_ENCODER_CONTRACTID_BASE "@mozilla.org/layout/documentEncoder;1?type="
  70.  
  71. // {7f915b01-98fc-11d4-8eb0-a803f80ff1bc}
  72. #define NS_HTMLCOPY_TEXT_ENCODER_CID                      \
  73. { 0x7f915b01, 0x98fc, 0x11d4, { 0x8e, 0xb0, 0xa8, 0x03, 0xf8, 0x0f, 0xf1, 0xbc } }
  74.  
  75. // {0BC1FAC0-B710-11d4-959F-0020183BF181}
  76. #define NS_IDOCUMENTENCODERNODEFIXUP_IID                     \
  77. { 0xbc1fac0, 0xb710, 0x11d4, { 0x95, 0x9f, 0x0, 0x20, 0x18, 0x3b, 0xf1, 0x81 } }
  78.   
  79. #define NS_HTMLCOPY_ENCODER_CONTRACTID "@mozilla.org/layout/htmlCopyEncoder;1"
  80.  
  81. class nsIDocumentEncoderNodeFixup : public nsISupports
  82. {
  83. public:
  84.  
  85.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENTENCODERNODEFIXUP_IID)
  86.  
  87.   /**
  88.    * Create a fixed up version of a node. This method is called before
  89.    * each node in a document is about to be persisted. The implementor
  90.    * may return a new node with fixed up attributes or nsnull. 
  91.    */
  92.   NS_IMETHOD FixupNode(nsIDOMNode *aNode, nsIDOMNode **aOutNode) = 0;
  93. };
  94.  
  95. class nsIDocumentEncoder : public nsISupports
  96. {
  97. public:
  98.  
  99.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_ENCODER_IID)
  100.  
  101.   /**
  102.    * Output methods flag bits.
  103.    *
  104.    * There are a frightening number of these,
  105.    * because everyone wants something a little bit different!
  106.    *
  107.    * These should move to an idl file so that Javascript can
  108.    * have access to the symbols, not just the constants.
  109.    */
  110.   enum {
  111.     // Output only the selection (as opposed to the whole document).
  112.     OutputSelectionOnly = 1,
  113.  
  114.     // Plaintext output: Convert html to plaintext that looks like the html.
  115.     // Implies wrap (except inside <pre>), since html wraps.
  116.     // HTML output: always do prettyprinting, ignoring existing formatting.
  117.     // (Probably not well tested for HTML output.)
  118.     OutputFormatted     = 2,
  119.  
  120.     // Don't do prettyprinting of HTML.  Don't do any wrapping that's not in
  121.     // the existing HTML source.  This option overrides OutputFormatted if both
  122.     // are set.  Note that this option does not affect entity conversion.
  123.     OutputRaw           = 4,
  124.  
  125.     // No html head tags
  126.     OutputBodyOnly      = 8,
  127.  
  128.     // Wrap even if we're not doing formatted output (e.g. for text fields)
  129.     // XXXbz this doesn't seem to be used by all serializers... document?  How
  130.     // does this interact with
  131.     // OutputFormatted/OutputRaw/OutputWrap/OutputFormatFlowed?
  132.     OutputPreformatted  = 16,
  133.  
  134.     // Output as though the content is preformatted
  135.     // (e.g. maybe it's wrapped in a MOZ_PRE or MOZ_PRE_WRAP style tag)
  136.     // XXXbz this doesn't seem to be used by all serializers... document?  How
  137.     // does this interact with
  138.     // OutputFormatted/OutputRaw/OutputPreformatted/OutputFormatFlowed?
  139.     OutputWrap          = 32,
  140.  
  141.     // Output for format flowed (RFC 2646). This is used when converting
  142.     // to text for mail sending. This differs just slightly
  143.     // but in an important way from normal formatted, and that is that
  144.     // lines are space stuffed. This can't (correctly) be done later.
  145.     // XXXbz this doesn't seem to be used by all serializers... document?  How
  146.     // does this interact with
  147.     // OutputFormatted/OutputRaw/OutputPreformatted/OutputWrap?
  148.     OutputFormatFlowed  = 64,
  149.  
  150.     // Convert links, image src, and script src to absolute URLs when possible
  151.     OutputAbsoluteLinks = 128,
  152.  
  153.     // Attempt to encode entities standardized at W3C (HTML, MathML, etc).
  154.     // This is a catch-all flag for documents with mixed contents. Beware of
  155.     // interoperability issues. See below for other flags which might likely
  156.     // do what you want.
  157.     OutputEncodeW3CEntities = 256,
  158.  
  159.     // LineBreak processing: we can do either platform line breaks,
  160.     // CR, LF, or CRLF.  If neither of these flags is set, then we
  161.     // will use platform line breaks.
  162.     OutputCRLineBreak = 512,
  163.     OutputLFLineBreak = 1024,
  164.  
  165.     // Output the content of noscript elements (only for serializing
  166.     // to plaintext).
  167.     OutputNoScriptContent = 2048,
  168.  
  169.     // Output the content of noframes elements (only for serializing
  170.     // to plaintext).
  171.     OutputNoFramesContent = 4096,
  172.  
  173.     // Don't allow any formatting nodes (e.g. <br>, <b>) inside a <pre>.
  174.     // This is used primarily by mail.
  175.     OutputNoFormattingInPre = 8192,
  176.  
  177.     // Encode entities when outputting to a string.
  178.     // E.g. If set, we'll output   if clear, we'll output 0xa0.
  179.     // The basic set is just   & < > " for interoperability
  180.     // with older products that don't support α and friends.
  181.     // The Latin1 entity set additionally includes 8bit accented letters
  182.     // between 128 and 255.
  183.     // The HTML entity set additionally includes accented letters, greek
  184.     // letters, and other special markup symbols as defined in HTML4.
  185.     OutputEncodeBasicEntities = 16384,
  186.     OutputEncodeLatin1Entities = 32768,
  187.     OutputEncodeHTMLEntities = 65536
  188.   };
  189.  
  190.   /**
  191.    *  Initialize with a pointer to the document and the mime type.
  192.    */
  193.   NS_IMETHOD Init(nsIDocument* aDocument, const nsAString& aMimeType,
  194.                   PRUint32 flags) = 0;
  195.  
  196.   /**
  197.    *  If the selection is set to a non-null value, then the
  198.    *  selection is used for encoding, otherwise the entire
  199.    *  document is encoded.
  200.    */
  201.   NS_IMETHOD SetSelection(nsISelection* aSelection) = 0;
  202.  
  203.   /**
  204.    *  If the range is set to a non-null value, then the
  205.    *  range is used for encoding, otherwise the entire
  206.    *  document or selection is encoded.
  207.    */
  208.   NS_IMETHOD SetRange(nsIDOMRange* aRange) = 0;
  209.  
  210.   /**
  211.    *  If the node is set to a non-null value, then the
  212.    *  node is used for encoding, otherwise the entire
  213.    *  document or range or selection is encoded.
  214.    */
  215.   NS_IMETHOD SetNode(nsIDOMNode* aNode) = 0;
  216.  
  217.   /**
  218.    *  Documents typically have an intrinsic character set.
  219.    *  If no intrinsic value is found, the platform character set
  220.    *  is used.
  221.    *  aCharset overrides the both the intrinsic or platform
  222.    *  character set when encoding the document.
  223.    *
  224.    *  Possible result codes: NS_ERROR_NO_CHARSET_CONVERTER
  225.    */
  226.   NS_IMETHOD SetCharset(const nsACString& aCharset) = 0;
  227.  
  228.   /**
  229.    *  Set a wrap column.  This may have no effect in some types of encoders.
  230.    */
  231.   NS_IMETHOD SetWrapColumn(PRUint32 aWC) = 0;
  232.  
  233.   /**
  234.    *  Get the mime type preferred by the encoder.  This piece of api was
  235.    *  added because the copy encoder may need to switch mime types on you
  236.    *  if you ask it to copy html that really represents plaintext content.
  237.    *  Call this AFTER Init() and SetSelection() have both been called.
  238.    */
  239.   NS_IMETHOD GetMimeType(nsAString& aMimeType) = 0;
  240.   
  241.   /**
  242.    *  The document is encoded, the result is sent to the 
  243.    *  to nsIOutputStream.
  244.    * 
  245.    *  Possible result codes are passing along whatever stream errors
  246.    *  might have been encountered.
  247.    */
  248.   NS_IMETHOD EncodeToStream(nsIOutputStream* aStream) = 0;
  249.   NS_IMETHOD EncodeToString(nsAString& aOutputString) = 0;
  250.  
  251.   /**
  252.    *  The document is encoded, the result is sent to the 
  253.    *  to aEncodedString.  Parent heirarchy information is encoded
  254.    *  to aContextString.  Extra context info is encoded in aInfoString.
  255.    * 
  256.    */
  257.   NS_IMETHOD EncodeToStringWithContext(nsAString& aEncodedString, 
  258.                                        nsAString& aContextString, 
  259.                                        nsAString& aInfoString) = 0;
  260.  
  261.   /**
  262.    * Set the fixup object associated with node persistence.
  263.    */
  264.   NS_IMETHOD SetNodeFixup(nsIDocumentEncoderNodeFixup *aFixup) = 0;
  265. };
  266.  
  267. #endif /* nsIDocumentEncoder_h__ */
  268.  
  269.